package JavaSE.d1;
import java.util.Scanner;

//十进制转二进制
public class Test4 {
    public static void main(String[] args) {
        int[] a=new int[100];
        int[] b=new int[100];
        int i=0;
        StringBuilder B= new StringBuilder();
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入十进制");
        int x=scanner.nextInt();
        while (x/2!=0){
            a[i]=x%2;
            i++;
            x=x/2;
        }
        a[i]=1;
        for (int j = a.length-1; j>0; j--) {
            if(a[j]==1){
                for (int k=j; k>=0;k-- ) {
                    B.append(a[k]);
                }
                System.out.println("该数字的二进制为"+B);
                break;
            }
        }
    }
}
